Repository navigation
Conversation
Fixes ml-explore#4460 The Scan primitive (backing cumsum, cumprod, cummin, cummax, and cumlogaddexp) was missing an output_shapes definition, causing mx.compile(..., shapeless=True) to fail with: [Primitive::output_shapes] CumSum cannot infer output shapes. Add DEFINE_INPUT_OUTPUT_SHAPE() to Scan so that it preserves the first input's shape during shapeless graph compilation. Added Python and C++ unit tests verifying dynamic shape execution. Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
Contributor
|
@somuai mind to tell which AI model you are using lollll. |
Member
|
Closing for violating contributing guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4460
Motivation
The
Scanprimitive (backingcumsum,cumprod,cummin,cummax, andcumlogaddexp) did not overridePrimitive::output_shapes. As a result, compiling a graph containing cumulative operations withshapeless=Truefailed with:Because all operations derived from
Scanpreserve their input tensor shape,Scan::output_shapescan safely return the first input's shape.Changes
DEFINE_INPUT_OUTPUT_SHAPE()toclass Scan : public UnaryPrimitiveinmlx/primitives.h.python/tests/test_compile.pyverifying dynamic shape execution across 1D and 2D arrays undermx.compile(..., shapeless=True).tests/compile_tests.cppasserting dynamic shape compilation withcumsum.